add testing for kml:dateTimeType. (#1112)
authortsteven4 <13596209+tsteven4@users.noreply.github.com>
Sun, 14 May 2023 20:25:04 +0000 (14:25 -0600)
committerGitHub <noreply@github.com>
Sun, 14 May 2023 20:25:04 +0000 (14:25 -0600)
and fix a related bug.

Note that we incorrectly, for kml:dateTimeType, force values
without time zone qualifiers to UTC.
We do not test the optional gYearMonth time zone qualifer.
We do not test the optional gYear time zone qualifer.
We do not test the optional date time zone qualifer.

gpx.cc
reference/xsddatetime.kml [new file with mode: 0644]
reference/xsddatetime~kml.csv [new file with mode: 0644]
testo.d/kml.test

diff --git a/gpx.cc b/gpx.cc
index 7b499a7d6cc26609cdf1b717aa2ee4d4c2d9ddea..4e591b33e2de11c4af5853f7624ad22b0bceda83 100644 (file)
--- a/gpx.cc
+++ b/gpx.cc
@@ -436,7 +436,7 @@ xml_parse_time(const QString& dateTimeString)
     *pointstr = '\0';
   }
 
-  int year = 0, mon = 0, mday = 0, hour = 0, min = 0, sec = 0;
+  int year = 0, mon = 1, mday = 1, hour = 0, min = 0, sec = 0;
   gpsbabel::DateTime dt;
   int res = sscanf(timestr, "%d-%d-%dT%d:%d:%d", &year, &mon, &mday, &hour,
                    &min, &sec);
diff --git a/reference/xsddatetime.kml b/reference/xsddatetime.kml
new file mode 100644 (file)
index 0000000..6fcb159
--- /dev/null
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2">
+  <Document>
+    <Placemark>
+      <name>gYear (YYYY)</name>
+      <TimeStamp>
+        <when>1997</when>
+      </TimeStamp>
+      <Point>
+        <coordinates>-116.865460,36.460850,-55.60</coordinates>
+      </Point>
+    </Placemark>
+    <Placemark>
+      <name>gYearMonth (YYYY-MM)</name>
+      <TimeStamp>
+        <when>1997-07</when>
+      </TimeStamp>
+      <Point>
+        <coordinates>-116.865460,36.460850,-55.60</coordinates>
+      </Point>
+    </Placemark>
+    <Placemark>
+      <name>date (YYYY-MM-DD)</name>
+      <TimeStamp>
+        <when>1997-07-16</when>
+      </TimeStamp>
+      <Point>
+        <coordinates>-116.865460,36.460850,-55.60</coordinates>
+      </Point>
+    </Placemark>
+    <Placemark>
+      <name>dateTime (YYYY-MM-DDThh:mm:ssZ)</name>
+      <TimeStamp>
+        <when>1997-07-16T07:30:15Z</when>
+      </TimeStamp>
+      <Point>
+        <coordinates>-116.865460,36.460850,-55.60</coordinates>
+      </Point>
+    </Placemark>
+    <Placemark>
+      <name>dateTime (YYYY-MM-DDThh:mm:sszzzzzz)</name>
+      <TimeStamp>
+        <when>1997-07-16T10:30:15+03:00</when>
+      </TimeStamp>
+      <Point>
+        <coordinates>-116.865460,36.460850,-55.60</coordinates>
+      </Point>
+    </Placemark>
+  </Document>
+</kml>
diff --git a/reference/xsddatetime~kml.csv b/reference/xsddatetime~kml.csv
new file mode 100644 (file)
index 0000000..0bcc26d
--- /dev/null
@@ -0,0 +1,6 @@
+No,Latitude,Longitude,Name,Altitude,Date,Time\r
+1,36.460850,-116.865460,"gYear (YYYY)",-55.6,1997/01/01,00:00:00\r
+2,36.460850,-116.865460,"gYearMonth (YYYY-MM)",-55.6,1997/07/01,00:00:00\r
+3,36.460850,-116.865460,"date (YYYY-MM-DD)",-55.6,1997/07/16,00:00:00\r
+4,36.460850,-116.865460,"dateTime (YYYY-MM-DDThh:mm:ssZ)",-55.6,1997/07/16,07:30:15\r
+5,36.460850,-116.865460,"dateTime (YYYY-MM-DDThh:mm:sszzzzzz)",-55.6,1997/07/16,07:30:15\r
index 3a65cb6c62abf7947c6d515c0229d4d182493234..212e3cbea640b6a731b2fd0d7907191a4bb400f1 100644 (file)
@@ -100,3 +100,8 @@ gpsbabel -i igc -f ${REFERENCE}/track/92GV66G1.igc -o kml,floating=1,track=1,poi
 compare  ${REFERENCE}/track/92GV66G1.igc.kml ${TMPDIR}/92GV66G1.igc.kml
 gpsbabel -i igc -f ${REFERENCE}/track/92HV66G1.igc -o kml,floating=1,track=1,points=0 -F ${TMPDIR}/92HV66G1.igc.kml
 compare  ${REFERENCE}/track/92HV66G1.igc.kml ${TMPDIR}/92HV66G1.igc.kml
+
+# verify kml:dateTimeType parsing
+gpsbabel -i kml -f ${REFERENCE}/xsddatetime.kml -o unicsv,utc -F ${TMPDIR}/xsddatetime~kml.csv
+compare ${REFERENCE}/xsddatetime~kml.csv ${TMPDIR}/xsddatetime~kml.csv
+